/**
 * @FileName: ThemesService.java
 * @Author
 * @Description:
 * @Date 2015年12月28日 下午3:26:32
 * @CopyRight ZTE Corporation
 */
package cn.hpclub.server.service;

import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

public class MemberWhiteService extends Service{
    public static MemberWhiteService service = new MemberWhiteService();

    /**
     * 获取查询语句
     */
    public String getSqlExceptSelect(ConcurrentHashMap<String, String> searchInfo){

        String sqlExceptSelect = "from member_white_list,(select DisplayName,NumCode,id,WebsiteId from organization)orgTable,(select user_name,name,member_type,org_id,emp_code from member_org)memOrg where memOrg.user_name=member_white_list.username  and orgTable.id=memOrg.org_id ";

        // sqlExceptSelect += " and member_org.org_id in("
        // + InterfaceUtil.getChlidOrgIdSql(InterfaceUtil.getOrgId(),
        // Constant.MAX_ORG_LEVEL, true) + ") ";

        for(Entry<String, String> item : searchInfo.entrySet()){
            sqlExceptSelect += buildQuery(item);
        }

        // System.out.println("sqlExceptSelect = " + sqlExceptSelect);
        return sqlExceptSelect;
    }

    private String buildQuery(Entry<String, String> item){

        String sql = "";
        if(item.getKey().equals("username")){
            sql += " and  member_white_list.username " + " like '%" + item.getValue() + "%'";
        }

        return sql;
    }

}
